package com.test;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletSession;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import com.liferay.portal.util.PortalUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;

/**
 * Portlet implementation class Local
 */
public class Local extends MVCPortlet {
	
	@Override
	public void doView(RenderRequest request, RenderResponse response) {
		String url = (String) PortalUtil.getCurrentURL(request);
		String path = "/html/local/view.jsp";
		String localId = "";
		String hotelId = "";
		if(url.indexOf("localId")!=-1)
		{
			if(url.indexOf("&")!=-1)
			{
				localId = url.substring(url.indexOf("localId"), url.indexOf("&"));
				
			}
			else
				localId = url.substring(url.indexOf("localId"), url.length());
			localId = localId.substring(localId.indexOf("=")+1,localId.length());
				path = "/html/local/local_item.jsp";
				path = path + "?localId="+localId;
			
		}
		
		if(url.indexOf("hotelId")!=-1)
		{
			hotelId = url.substring(url.indexOf("hotelId"), url.length());
			hotelId = hotelId.substring(hotelId.indexOf("=")+1,hotelId.length() );
			
			path = "/html/hotel/hotel_item.jsp";
			path = path + "?hotelId="+hotelId;
		}
		
		try {
			include(path, request, response);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (PortletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
 

}
